<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos  -->
			<title>File Source for cat.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
											</head>
		<body>
						<h1>Source for file cat.php</h1>
<p>Documentation is available at <a href="../myLiveShop/_core_cat_php.html">cat.php</a></p>
<div class="src-code">
<pre><ol><li><a name="a1"></a><span class="src-php">&lt;?php</span></li>
<li><a name="a2"></a><span class="src-doc">/**</span></li>
<li><a name="a3"></a><span class="src-doc"> * Работа с каталогами</span></li>
<li><a name="a4"></a><span class="src-doc"> * </span></li>
<li><a name="a5"></a><span class="src-doc"> * Класс для работы с каталогами</span></li>
<li><a name="a6"></a><span class="src-doc"> * </span></li>
<li><a name="a7"></a><span class="src-doc"> * (Не закончена)</span></li>
<li><a name="a8"></a><span class="src-doc"> * </span></li>
<li><a name="a9"></a><span class="src-doc"> * </span></li>
<li><a name="a10"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@author</span><span class="src-doc"> Anton Zavidov</span></li>
<li><a name="a11"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@package</span><span class="src-doc"> myLiveShop</span></li>
<li><a name="a12"></a><span class="src-doc"> */</span></li>
<li><a name="a13"></a>&nbsp;</li>
<li><a name="a14"></a><span class="src-doc">/**</span></li>
<li><a name="a15"></a><span class="src-doc"> * Базовый класс для работы с каталогами</span></li>
<li><a name="a16"></a><span class="src-doc"> *</span></li>
<li><a name="a17"></a><span class="src-doc"> */</span></li>
<li><a name="a18"></a><span class="src-key">class </span><a href="../myLiveShop/Cat.html">Cat</a> <span class="src-key">extends </span><a href="../myLiveShop/Base.html">Base</a> <span class="src-sym">{</span></li>
<li><a name="a19"></a>    <span class="src-doc">/**</span></li>
<li><a name="a20"></a><span class="src-doc">     * Инстанс класа</span></li>
<li><a name="a21"></a><span class="src-doc">     *</span></li>
<li><a name="a22"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">File </span></li>
<li><a name="a23"></a><span class="src-doc">     */</span></li>
<li><a name="a24"></a>    <span class="src-key">private </span><span class="src-key">static </span><span class="src-var">$instance</span><span class="src-sym">;</span></li>
<li><a name="a25"></a>    <span class="src-doc">/**</span></li>
<li><a name="a26"></a><span class="src-doc">     * Текущ путь дериктории</span></li>
<li><a name="a27"></a><span class="src-doc">     *</span></li>
<li><a name="a28"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a29"></a><span class="src-doc">     */</span></li>
<li><a name="a30"></a>    <span class="src-key">private </span><a href="../myLiveShop/Cat.html#var$part">$part</a><span class="src-sym">;</span></li>
<li><a name="a31"></a>    <span class="src-doc">/**</span></li>
<li><a name="a32"></a><span class="src-doc">     * Настройки получаемой инцормации</span></li>
<li><a name="a33"></a><span class="src-doc">     * </span></li>
<li><a name="a34"></a><span class="src-doc">     * onlyDir=true возвращает только папки</span></li>
<li><a name="a35"></a><span class="src-doc">     * onlyFile=true возвращает только файлы</span></li>
<li><a name="a36"></a><span class="src-doc">     * mask=&quot;&quot; маска для поисков файлов по имени</span></li>
<li><a name="a37"></a><span class="src-doc">     * extentions=array() список допустимых расширений</span></li>
<li><a name="a38"></a><span class="src-doc">     * return=&quot;list/tree&quot;</span></li>
<li><a name="a39"></a><span class="src-doc">     * deep=0 глубина вложенности если 0 то бесконечно</span></li>
<li><a name="a40"></a><span class="src-doc">     * detail=array(&quot;ext&quot;,&quot;size&quot;,&quot;date&quot;,&quot;part&quot;,&quot;counter&quot;) возвращаемая информация о файле</span></li>
<li><a name="a41"></a><span class="src-doc">     *</span></li>
<li><a name="a42"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">array </span></li>
<li><a name="a43"></a><span class="src-doc">     */</span></li>
<li><a name="a44"></a>    <span class="src-key">private </span><a href="../myLiveShop/Cat.html#var$settings">$settings</a>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a45"></a>    <span class="src-key">public </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a46"></a>        <span class="src-id">parent</span><span class="src-sym">::</span><a href="../myLiveShop/Base.html#method__construct">__construct</a><span class="src-sym">(</span>__CLASS__<span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a47"></a>    <span class="src-sym">}</span></li>
<li><a name="a48"></a>    <span class="src-doc">/**</span></li>
<li><a name="a49"></a><span class="src-doc">     * Поличение инстанса класса</span></li>
<li><a name="a50"></a><span class="src-doc">     *</span></li>
<li><a name="a51"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">File </span></li>
<li><a name="a52"></a><span class="src-doc">     */</span></li>
<li><a name="a53"></a>    <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#methodgetInstance">getInstance</a><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a54"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$instance </span>=== <span class="src-id">null</span><span class="src-sym">)</span></li>
<li><a name="a55"></a>        <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$instance </span>= <span class="src-key">new </span><span class="src-id">self</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a56"></a>        <span class="src-key">else</span></li>
<li><a name="a57"></a>        <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$instance</span><span class="src-sym">;</span></li>
<li><a name="a58"></a>    <span class="src-sym">}</span></li>
<li><a name="a59"></a>    <span class="src-key">public </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#method_">_</a><span class="src-sym">(</span><span class="src-var">$part</span>=<span class="src-id">null</span><span class="src-sym">,</span><span class="src-var">$settings</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a60"></a>        <span class="src-var">$self</span>=<span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getInstance</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a61"></a>        <span class="src-comm">//возвращает инстанс ели ничего не переданно</span></li>
<li><a name="a62"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$part</span>===<span class="src-id">null</span><span class="src-sym">)</span><span class="src-key">return </span><span class="src-var">$self</span><span class="src-sym">;</span></li>
<li><a name="a63"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$part</span><span class="src-sym">)</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">part</span>=<span class="src-var">$part</span><span class="src-sym">;</span></li>
<li><a name="a64"></a>        <span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span>=<span class="src-var">$settings</span><span class="src-sym">;</span></li>
<li><a name="a65"></a>        <span class="src-var">$return</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a66"></a>        <span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">get</span><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">part</span><span class="src-sym">,</span><span class="src-var">$self</span><span class="src-sym">,</span><span class="src-num">1</span><span class="src-sym">,</span><span class="src-var">$return</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a67"></a>        <span class="src-key">return </span><span class="src-var">$return</span><span class="src-sym">;</span></li>
<li><a name="a68"></a>    <span class="src-sym">}</span></li>
<li><a name="a69"></a>    <span class="src-key">private </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#methodget">get</a><span class="src-sym">(</span><span class="src-var">$part</span><span class="src-sym">,</span><span class="src-var">$self</span><span class="src-sym">,</span><span class="src-var">$deep</span><span class="src-sym">,</span><span class="src-sym">&amp;</span><span class="src-var">$return</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a70"></a>        <span class="src-comm">//проверяем уровень вложенности</span></li>
<li><a name="a71"></a>        <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'deep'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-var">$deep</span>&gt;<span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'deep'</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-key">return </span><span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a72"></a>        <span class="src-comm">//читаем дерикторию</span></li>
<li><a name="a73"></a>        <span class="src-var">$d </span>= <a href="http://www.php.net/dir">dir</a><span class="src-sym">(</span><span class="src-var">$part</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a74"></a>        <span class="src-key">while </span><span class="src-sym">(</span><span class="src-id">false </span>!== <span class="src-sym">(</span><span class="src-var">$entry </span>= <span class="src-var">$d</span><span class="src-sym">-&gt;</span><span class="src-id">read</span><span class="src-sym">(</span><span class="src-sym">))) </span><span class="src-sym">{</span></li>
<li><a name="a75"></a>            <span class="src-comm">//отбрасываем ссылки на уровни</span></li>
<li><a name="a76"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$entry</span>==<span class="src-str">&quot;.&quot; </span>|| <span class="src-var">$entry</span>==<span class="src-str">&quot;..&quot;</span><span class="src-sym">)</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a77"></a>            <span class="src-comm">//получаем тип файла</span></li>
<li><a name="a78"></a>            <span class="src-var">$fileType</span>=<a href="http://www.php.net/filetype">filetype</a><span class="src-sym">(</span><span class="src-var">$part</span>.<span class="src-str">&quot;/&quot;</span>.<span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a79"></a>            <span class="src-var">$ext</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">;</span></li>
<li><a name="a80"></a>            <span class="src-var">$fileName</span>=<span class="src-var">$entry</span><span class="src-sym">;</span></li>
<li><a name="a81"></a>            <span class="src-comm">//получаем расширение файла</span></li>
<li><a name="a82"></a>            <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$entry</span><span class="src-sym">,</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a83"></a>                <span class="src-var">$ext</span>=<a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">,</span><span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a84"></a>                <span class="src-var">$ext</span>=<span class="src-var">$ext</span><span class="src-sym">[</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$ext</span><span class="src-sym">)</span>-<span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a85"></a>                <span class="src-var">$fileName</span>=<a href="http://www.php.net/trim">trim</a><span class="src-sym">(</span><span class="src-var">$entry</span><span class="src-sym">,</span><span class="src-str">&quot;.&quot;</span>.<span class="src-var">$ext</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a86"></a>            <span class="src-sym">}</span></li>
<li><a name="a87"></a>            <span class="src-comm">//отбрасываем не файлы и не папки</span></li>
<li><a name="a88"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$fileType</span>!=<span class="src-str">&quot;dir&quot; </span>&amp;&amp; <span class="src-var">$fileType</span>!=<span class="src-str">&quot;file&quot;</span><span class="src-sym">)</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a89"></a>            <span class="src-comm">//отбрасываем не папки если стоит флаг onlyDir</span></li>
<li><a name="a90"></a>            <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'onlyDir'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-var">$fileType</span>!=<span class="src-str">&quot;dir&quot;</span><span class="src-sym">)</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a91"></a>            <span class="src-comm">//отбрасываем не файлы если стоит флаг onlyFile</span></li>
<li><a name="a92"></a>            <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'onlyFile'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-var">$fileType</span>!=<span class="src-str">&quot;file&quot;</span><span class="src-sym">)</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a93"></a>            <span class="src-comm">//провевяем допустимые расширения файлов</span></li>
<li><a name="a94"></a>            <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'extentions'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'extentions'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-var">$fileType</span>==<span class="src-str">&quot;file&quot;</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a95"></a>                <span class="src-var">$found</span>=<span class="src-id">false</span><span class="src-sym">;    </span></li>
<li><a name="a96"></a>                <span class="src-comm">//проходим по списку допустимых расширений</span></li>
<li><a name="a97"></a>                <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'extentions'</span><span class="src-sym">] </span><span class="src-key">as </span><span class="src-var">$item</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a98"></a>                    <span class="src-key">if</span><span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$ext</span><span class="src-sym">)</span>==<a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$item</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a99"></a>                        <span class="src-var">$found</span>=<span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a100"></a>                        <span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a101"></a>                    <span class="src-sym">}</span></li>
<li><a name="a102"></a>                <span class="src-sym">}</span></li>
<li><a name="a103"></a>                <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$found</span><span class="src-sym">)</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a104"></a>            <span class="src-sym">}</span></li>
<li><a name="a105"></a>            <span class="src-comm">//проверяем имя файла по маске</span></li>
<li><a name="a106"></a>            <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'mask'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-sym">!</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'mask'</span><span class="src-sym">]</span><span class="src-sym">,</span><span class="src-var">$fileName</span><span class="src-sym">))</span><span class="src-key">continue</span><span class="src-sym">;</span></li>
<li><a name="a107"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$fileType</span>==<span class="src-str">'file'</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a108"></a>                <span class="src-comm">//если стоит флаг детальной информации то собираем её</span></li>
<li><a name="a109"></a>                <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a110"></a>                    <span class="src-var">$result</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">&quot;fileName&quot;</span>=&gt;<span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a111"></a>                    <span class="src-comm">//записываем расширение</span></li>
<li><a name="a112"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'extentions'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'ext'</span><span class="src-sym">]</span>=<span class="src-var">$ext</span><span class="src-sym">;</span></li>
<li><a name="a113"></a>                    <span class="src-comm">//записывам путь</span></li>
<li><a name="a114"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'part'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'part'</span><span class="src-sym">]</span>=<span class="src-var">$part</span><span class="src-sym">;</span></li>
<li><a name="a115"></a>                    <span class="src-comm">//записываем дату создания, дотупа и изменения</span></li>
<li><a name="a116"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'date'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a117"></a>                        <span class="src-var">$info</span>=<a href="http://www.php.net/stat">stat</a><span class="src-sym">(</span><span class="src-var">$part</span>.<span class="src-str">&quot;/&quot;</span>.<span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a118"></a>                        <span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'info'</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span></li>
<li><a name="a119"></a>                            <span class="src-str">'last'</span>=&gt;<span class="src-var">$info</span><span class="src-sym">[</span><span class="src-str">'atime'</span><span class="src-sym">]</span><span class="src-sym">,</span></li>
<li><a name="a120"></a>                            <span class="src-str">'create'</span>=&gt;<span class="src-var">$info</span><span class="src-sym">[</span><span class="src-str">'mtime'</span><span class="src-sym">]</span><span class="src-sym">,</span></li>
<li><a name="a121"></a>                            <span class="src-str">'change'</span>=&gt;<span class="src-var">$info</span><span class="src-sym">[</span><span class="src-str">'ctime'</span><span class="src-sym">]</span><span class="src-sym">,</span></li>
<li><a name="a122"></a>                        <span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a123"></a>                    <span class="src-sym">}</span></li>
<li><a name="a124"></a>                    <span class="src-comm">//записываем длину файла</span></li>
<li><a name="a125"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'size'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a126"></a>                        <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'date'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'size'</span><span class="src-sym">]</span>=<span class="src-var">$info</span><span class="src-sym">[</span><span class="src-str">'size'</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a127"></a>                        <span class="src-key">else </span><span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'size'</span><span class="src-sym">]</span>=<a href="http://www.php.net/filesize">filesize</a><span class="src-sym">(</span><span class="src-var">$part</span>.<span class="src-str">&quot;/&quot;</span>.<span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a128"></a>                    <span class="src-sym">}</span></li>
<li><a name="a129"></a>                    <span class="src-var">$result</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$result</span><span class="src-sym">;</span></li>
<li><a name="a130"></a>                <span class="src-sym">}</span><span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a131"></a>                    <span class="src-comm">//иначе просто записывам имя файла</span></li>
<li><a name="a132"></a>                    <span class="src-var">$return</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$entry</span><span class="src-sym">;</span></li>
<li><a name="a133"></a>                <span class="src-sym">}</span></li>
<li><a name="a134"></a>            <span class="src-sym">}</span><span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a135"></a>                <span class="src-var">$subLevel</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a136"></a>                <span class="src-comm">//получаем подпапки</span></li>
<li><a name="a137"></a>                <span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">get</span><span class="src-sym">(</span><span class="src-var">$part</span>.<span class="src-str">&quot;/&quot;</span>.<span class="src-var">$entry</span><span class="src-sym">,</span><span class="src-var">$self</span><span class="src-sym">,</span><span class="src-var">$deep</span>+<span class="src-num">1</span><span class="src-sym">,</span><span class="src-var">$subLevel</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a138"></a>                <span class="src-comm">//если стоит флаг детальной информации то собираем её</span></li>
<li><a name="a139"></a>                <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a140"></a>                    <span class="src-var">$result</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">&quot;dirName&quot;</span>=&gt;<span class="src-var">$entry</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a141"></a>                    <span class="src-comm">//записывам путь</span></li>
<li><a name="a142"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'part'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'part'</span><span class="src-sym">]</span>=<span class="src-var">$part</span><span class="src-sym">;</span></li>
<li><a name="a143"></a>                    <span class="src-comm">//считаем сколько файлов в папке и сколько в падпапках</span></li>
<li><a name="a144"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'counter'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a145"></a>                        <span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'counter'</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><a href="http://www.php.net/count">count</a><span class="src-sym">(</span><span class="src-var">$subLevel</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a146"></a>                        <span class="src-var">$count</span>=<span class="src-num">0</span><span class="src-sym">;</span></li>
<li><a name="a147"></a>                        <span class="src-comm">//считаем в подпапках</span></li>
<li><a name="a148"></a>                        <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$subLevel </span><span class="src-key">as </span><span class="src-var">$item</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a149"></a>                            <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$item</span><span class="src-sym">[</span><span class="src-str">'counter'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-var">$count</span>+=<span class="src-var">$item</span><span class="src-sym">[</span><span class="src-str">'counter'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a150"></a>                            <span class="src-var">$count</span>++<span class="src-sym">;</span></li>
<li><a name="a151"></a>                        <span class="src-sym">}</span></li>
<li><a name="a152"></a>                        <span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'counter'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$count</span><span class="src-sym">;</span></li>
<li><a name="a153"></a>                    <span class="src-sym">}</span></li>
<li><a name="a154"></a>                <span class="src-sym">}</span></li>
<li><a name="a155"></a>                <span class="src-comm">//в зависимости от типа вывода записываем данные</span></li>
<li><a name="a156"></a>                <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'return'</span><span class="src-sym">]</span><span class="src-sym">) </span>&amp;&amp; <span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'return'</span><span class="src-sym">]</span>==<span class="src-str">'tree'</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a157"></a>                    <span class="src-key">if</span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">settings</span><span class="src-sym">[</span><span class="src-str">'detail'</span><span class="src-sym">]</span><span class="src-sym">))</span><span class="src-sym">{</span></li>
<li><a name="a158"></a>                        <span class="src-var">$result</span><span class="src-sym">[</span><span class="src-str">'sublevel'</span><span class="src-sym">]</span>=<span class="src-var">$subLevel</span><span class="src-sym">;</span></li>
<li><a name="a159"></a>                        <span class="src-var">$return</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-var">$result</span><span class="src-sym">;</span></li>
<li><a name="a160"></a>                    <span class="src-sym">}</span><span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a161"></a>                        <span class="src-var">$return</span><span class="src-sym">[</span><span class="src-sym">]</span>=<span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$entry</span><span class="src-sym">,</span><span class="src-var">$subLevel</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a162"></a>                    <span class="src-sym">}</span></li>
<li><a name="a163"></a>                <span class="src-sym">}</span><span class="src-key">else</span><span class="src-sym">{</span></li>
<li><a name="a164"></a>                    <span class="src-var">$return</span>=<a href="http://www.php.net/array_merge">array_merge</a><span class="src-sym">(</span><span class="src-var">$return</span><span class="src-sym">,</span><span class="src-var">$subLevel</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a165"></a>                <span class="src-sym">}</span></li>
<li><a name="a166"></a>&nbsp;</li>
<li><a name="a167"></a>            <span class="src-sym">}</span></li>
<li><a name="a168"></a>        <span class="src-sym">}</span></li>
<li><a name="a169"></a>        <span class="src-var">$d</span><span class="src-sym">-&gt;</span><span class="src-id">close</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a170"></a>    <span class="src-sym">}</span></li>
<li><a name="a171"></a>    <span class="src-doc">/**</span></li>
<li><a name="a172"></a><span class="src-doc">     * Устанавливаем путь</span></li>
<li><a name="a173"></a><span class="src-doc">     *</span></li>
<li><a name="a174"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$part </span></li>
<li><a name="a175"></a><span class="src-doc">     * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">class </span></li>
<li><a name="a176"></a><span class="src-doc">     */</span></li>
<li><a name="a177"></a>    <span class="src-key">public </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#methodsetPart">setPart</a><span class="src-sym">(</span><span class="src-var">$part</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a178"></a>        <span class="src-var">$self</span>=<span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getInstance</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a179"></a>        <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$part</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a180"></a>            <span class="src-key">new </span><span class="src-id"><a href="../myLiveShop/CoreExeption.html">CoreExeption</a></span><span class="src-sym">(</span><span class="src-str">'Не указан путь'</span><span class="src-sym">,</span><span class="src-id">E_ERROR</span><span class="src-sym">,</span>__FILE__<span class="src-sym">,</span>__LINE__<span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a181"></a>            <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a182"></a>        <span class="src-sym">}</span></li>
<li><a name="a183"></a>        <span class="src-var">$self</span><span class="src-sym">-&gt;</span><span class="src-id">part</span>=<span class="src-var">$part</span><span class="src-sym">;</span></li>
<li><a name="a184"></a>        <span class="src-key">return </span><span class="src-var">$self</span><span class="src-sym">;</span></li>
<li><a name="a185"></a>    <span class="src-sym">}</span></li>
<li><a name="a186"></a>    <span class="src-key">public </span><span class="src-key">function </span><a href="../myLiveShop/Cat.html#method__toString">__toString</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a187"></a>        <span class="src-key">return </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../myLiveShop/Cat.html#var$part">part</a><span class="src-sym">;</span></li>
<li><a name="a188"></a>    <span class="src-sym">}</span></li>
<li><a name="a189"></a><span class="src-sym">}</span></li>
</ol></pre>
</div>
	<p class="notes" id="credit">
		Документ создан Mon, 14 Feb 2011 01:08:25 +0200 в <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
	</p>
	</body>
</html>